package com.open.spi;

import java.util.Iterator;
import java.util.ServiceLoader;

public class ServiceLoaderTest {

    //TODO 复习SPI 和 ClassLoader ServiceLoader
    public static void main(String[] args) throws ClassNotFoundException {

        //指向 META-INF/services/com.open.spi.IA
        ServiceLoader<IA> serviceLoader = ServiceLoader.load(IA.class);

        Iterator<IA> iterator = serviceLoader.iterator();
        while (iterator.hasNext()){
            IA next = iterator.next();//这一步会实例化类,调用无参构造函数
        }
    }



}
